package yns.springboot.guide.demo.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import yns.springboot.guide.demo.aop.annotation.CommonAnnotation;
import yns.springboot.guide.demo.aop.annotation.LogAnnotation;

@RestController
public class TestAopController extends BaseController {

	// http://localhost:8080/aop/test
	// http://localhost:8080/aop/annotation/test

	private final Logger logger = LoggerFactory.getLogger(this.getClass());

	@RequestMapping("/aop/{msg}")
	public String testAop(String test, @PathVariable(value = "msg") String msg) {
		logger.info(httpServletRequest.getRequestURI());
		logger.info("testAop : test=" + test + "  msg=" + msg);
		return "testAop";
	}

	@RequestMapping("/aop/annotation/{msg}")
	@LogAnnotation
	@CommonAnnotation(name = "testAnnotationName")
	public String testAnnotation(String test, @PathVariable(value = "msg") String msg) {
		logger.info(httpServletRequest.getRequestURI());
		logger.info("testAnnotation : test=" + test + "  msg=" + msg);
		return "testAnnotation";
	}

}
